﻿@namespace BootstrapBlazor.Components
@inherits BootstrapModuleComponentBase
@attribute [BootstrapModuleAutoLoader("Modal/ModalDialog.razor.js", JSObjectReference = true)]

<div class="@ClassName" id="@Id">
    <div class="modal-content">
        @if (ShowHeader)
        {
            <div class="modal-header">
                @if (HeaderTemplate != null)
                {
                    @HeaderTemplate
                }
                else
                {
                    <h5 class="modal-title flex-fill">@Title</h5>
                }
                <div class="modal-header-buttons">
                    @if (HeaderToolbarTemplate != null)
                    {
                        @HeaderToolbarTemplate
                    }
                    @if (ShowPrintButton && ShowPrintButtonInHeader)
                    {
                        <PrintButton Color="Color.Primary" class="btn-print" Text="@PrintButtonText"></PrintButton>
                    }
                    @if (ShowMaximizeButton)
                    {
                        <Button Color="Color.None" class="btn-maximize" aria-label="@MaximizeAriaLabel" OnClick="@OnToggleMaximize" Icon="@MaximizeIconString"></Button>
                    }
                    @if (ShowHeaderCloseButton)
                    {
                        <Button Color="Color.None" class="btn-close" aria-label="Close" OnClickWithoutRender="@OnClickCloseAsync"></Button>
                    }
                </div>
            </div>
        }
        <CascadingValue Name="BodyContext" Value="@BodyContext" IsFixed="true">
            <CascadingValue Value="OnClickCloseAsync" IsFixed="true">
                <div class="modal-body">
                    @RenderBodyTemplate()
                </div>
                @if (ShowFooter)
                {
                    <div class="modal-footer">
                        @if (ShowCloseButton)
                        {
                            <DialogCloseButton Text="@CloseButtonText" Icon="@CloseButtonIcon"></DialogCloseButton>
                        }
                        @if (ShowPrintButton && !ShowPrintButtonInHeader)
                        {
                            <PrintButton Color="Color.Primary" class="btn-print" Text="@PrintButtonText"></PrintButton>
                        }
                        @if (ShowSaveButton)
                        {
                            <Button Color="Color.Primary" Text="@SaveButtonText" Icon="@SaveIcon" OnClickWithoutRender="OnClickSave"></Button>
                        }
                        @if (FooterTemplate != null)
                        {
                            @FooterTemplate
                        }
                    </div>
                }
                @if (ShowResize)
                {
                    <svg class="modal-resizer" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M319.20128 974.56128L348.16 1003.52l655.36-655.36-28.95872-28.95872-655.36 655.36zM675.84 1003.52l327.68-327.68-28.95872-28.95872-327.68 327.68L675.84 1003.52z"></path></svg>
                }
            </CascadingValue>
        </CascadingValue>
    </div>
</div>
